package lab02.test23;

import java.util.Calendar;
import java.util.Date;
import java.util.Scanner;

public class Test23 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入你的生日（如2017-09-21）：");
        String str = sc.nextLine();

        String year = str.substring(0,4);
        String month = str.substring(5,7);
        String day = str.substring(8);

        Calendar cal = Calendar.getInstance();//用来获取当前的日期
        cal.set(Integer.parseInt(year),Integer.parseInt(month),Integer.parseInt(day));

        //判断生日星期几,使用DAY—OF—WEEK判断星期
        int week = cal.get(Calendar.DAY_OF_WEEK);
        switch (week){
            case 1:
                System.out.println("你的生日在星期一");
                break;
            case 2:
                System.out.println("你的生日在星期二");
                break;
            case 3:
                System.out.println("你的生日在星期三");
                break;
            case 4:
                System.out.println("你的生日在星期四");
                break;
            case 5:
                System.out.println("你的生日在星期五");
                break;
            case 6:
                System.out.println("你的生日在星期六");
                break;
            default:
                System.out.println("你的生日在周天");
                break;
        }
        //判断距离生日还有多少天
        Date date = new Date();
        cal.set(2017,Integer.parseInt(month),Integer.parseInt(day));//获取目前的年月日
        Date date1 = cal.getTime();
        long number = (date1.getTime()-date.getTime())/(24*60*60*1000);
        if (number < 0){
            cal.set(2018,Integer.parseInt(month),Integer.parseInt(day));
            date1 = cal.getTime();
            number = (date1.getTime()-date.getTime())/(24*60*60*1000);
        }
        System.out.println("距离你的生日还有"+number+"天");

    }
}
